﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Root="clr-namespace:Elysium.Theme">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Elysium.Theme;component/Themes/SharedResources.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type RadioButton}">
        
        <Setter Property="Background" Value="{StaticResource Transparent}"/>
        <Setter Property="BorderBrush" Value="{StaticResource ForegroundMiddlelight}"/>
        <Setter Property="BorderThickness" Value="{x:Static Root:Parameters.DefaultThickness}"/>
        <Setter Property="Foreground" Value="{StaticResource Foreground}"/>
        <Setter Property="FontFamily" Value="{x:Static Root:Parameters.FontFamily}"/>
        <Setter Property="FontSize" Value="{x:Static Root:Parameters.ContentFontSize}"/>
        <Setter Property="FontWeight" Value="Normal"/>

        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}"/>

        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="Padding" Value="{x:Static Root:Parameters.BoldPadding}"/>

        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RadioButton}">
                    
                    <Grid Background="{StaticResource Transparent}"
                          Margin="{TemplateBinding Padding}"
                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <BulletDecorator Background="{StaticResource Transparent}"
                                         TextBlock.Foreground="{TemplateBinding Foreground}"
                                         TextBlock.FontFamily="{TemplateBinding FontFamily}"
                                         TextBlock.FontSize="{TemplateBinding FontSize}"
                                         TextBlock.FontWeight="{TemplateBinding FontWeight}"
                                         FlowDirection="{TemplateBinding FlowDirection}">
                            <BulletDecorator.Bullet>
                                <Grid Background="{StaticResource Transparent}"
                                      Width="{TemplateBinding Root:Parameters.BulletDecoratorSize}" Height="{TemplateBinding Root:Parameters.BulletDecoratorSize}">
                                    <Ellipse Fill="{TemplateBinding Background}"
                                             Stroke="{TemplateBinding BorderBrush}"
                                             StrokeThickness="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness.Left}"/>
                                    <Ellipse x:Name="CheckBullet"
                                             Fill="{StaticResource ForegroundLowlight}"
                                             StrokeThickness="0"
                                             Visibility="Collapsed"
                                             HorizontalAlignment="Center" VerticalAlignment="Center"
                                             Width="{TemplateBinding Root:Parameters.RadioButtonBulletSize}" Height="{TemplateBinding Root:Parameters.RadioButtonBulletSize}">
                                    </Ellipse>
                                </Grid>
                            </BulletDecorator.Bullet>
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              RecognizesAccessKey="True">
                                <ContentPresenter.Margin>
                                    <Thickness Left="{x:Static Root:Parameters.BoldPaddingValue}"
                                               Top="0"
                                               Right="0"
                                               Bottom="0"/>
                                </ContentPresenter.Margin>
                            </ContentPresenter>
                        </BulletDecorator>
                    </Grid>
                    
                    <ControlTemplate.Triggers>                        
                        <Trigger Property="IsChecked" Value="True">
                            <Setter TargetName="CheckBullet" Property="Visibility" Value="Visible"/>
                        </Trigger>                        
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="CheckBullet" Property="Ellipse.Fill" Value="{StaticResource Disabled}"/>
                        </Trigger>                        
                    </ControlTemplate.Triggers>
                    
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        
        <Style.Triggers>            
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{StaticResource ForegroundHighlight}"/>
                <Setter Property="BorderBrush" Value="{StaticResource ForegroundMiddlelight}"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{StaticResource ForegroundHighlight}"/>
                <Setter Property="BorderBrush" Value="{StaticResource ForegroundLowlight}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="{StaticResource Transparent}"/>
                <Setter Property="BorderBrush" Value="{StaticResource Disabled}"/>
                <Setter Property="Foreground" Value="{StaticResource Disabled}"/>
            </Trigger>
        </Style.Triggers>  
        
    </Style>

</ResourceDictionary>